轮播图点击事件

chengzhenyu 8 lat temu
rodzic
commit
ba98dcf437

+ 2 - 1
app/src/main/java/ai/pai/client/fragments/TabRecentPhotoFragment.java

@@ -39,6 +39,7 @@ import ai.pai.client.db.DBService;
39 39
 import ai.pai.client.db.Preferences;
40 40
 import ai.pai.client.utils.HttpPostTask;
41 41
 import ai.pai.client.utils.UrlContainer;
42
+import ai.pai.client.views.FullScreenImgPopup;
42 43
 
43 44
 public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener,OnItemClickListener {
44 45
 
@@ -292,7 +293,7 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
292 293
 
293 294
     @Override
294 295
     public void onItemClick(int position) {
295
-        Toast.makeText(getActivity(),bannerBeanList.get(position).title,Toast.LENGTH_SHORT).show();
296
+        new FullScreenImgPopup(getActivity(),bannerBeanList.get(position).url).showPopupWindow();
296 297
     }
297 298
 
298 299
     public class NetworkImageHolderView implements Holder<String> {

+ 68 - 0
app/src/main/java/ai/pai/client/views/FullScreenImgPopup.java

@@ -0,0 +1,68 @@
1
+package ai.pai.client.views;
2
+
3
+import android.app.Activity;
4
+import android.content.Context;
5
+import android.view.LayoutInflater;
6
+import android.view.View;
7
+import android.view.animation.Animation;
8
+import android.widget.ImageView;
9
+
10
+import com.android.views.PhotoView.UrlTouchImageView;
11
+import com.android.views.popup.BasePopupWindow;
12
+
13
+import ai.pai.client.R;
14
+import ai.pai.client.utils.GroupCreateUtils;
15
+
16
+/**
17
+ * Created by chengzhenyu on 2016/3/4.
18
+ */
19
+public class FullScreenImgPopup extends BasePopupWindow {
20
+
21
+    private View popupView;
22
+    private String imgUrl;
23
+    private UrlTouchImageView fullScreenImg;
24
+    private ImageView backImg;
25
+    private Context context;
26
+
27
+
28
+    public FullScreenImgPopup(Activity context, String imgUrl) {
29
+        super(context);
30
+        this.imgUrl = imgUrl;
31
+        this.context = context;
32
+        init();
33
+    }
34
+
35
+    @Override
36
+    protected Animation getShowAnimation() {
37
+        return getDefaultScaleAnimation();
38
+    }
39
+
40
+    @Override
41
+    protected View getClickToDismissView() {
42
+        return popupView.findViewById(R.id.click_to_dismiss);
43
+    }
44
+
45
+    @Override
46
+    public View getPopupView() {
47
+        popupView = LayoutInflater.from(mContext).inflate(R.layout.pop_full_screen_img, null);
48
+        fullScreenImg = (UrlTouchImageView) popupView.findViewById(R.id.iv_full_screen_img);
49
+        backImg = (ImageView)popupView.findViewById(R.id.iv_pop_back);
50
+        return popupView;
51
+    }
52
+
53
+    private void init() {
54
+        fullScreenImg.setUrl(imgUrl);
55
+        backImg.setOnClickListener(new View.OnClickListener(){
56
+            @Override
57
+            public void onClick(View v) {
58
+                dismiss();
59
+            }
60
+        });
61
+    }
62
+
63
+    @Override
64
+    public View getAnimaView() {
65
+        return popupView.findViewById(R.id.popup_anima);
66
+    }
67
+
68
+}

+ 44 - 0
app/src/main/res/layout/pop_full_screen_img.xml

@@ -0,0 +1,44 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent">
5
+
6
+    <RelativeLayout
7
+        android:id="@+id/click_to_dismiss"
8
+        android:layout_width="match_parent"
9
+        android:layout_height="match_parent"
10
+        android:background="@color/popup_bg">
11
+
12
+        <LinearLayout
13
+            android:id="@+id/popup_anima"
14
+            android:layout_width="match_parent"
15
+            android:layout_height="match_parent"
16
+            android:layout_centerInParent="true"
17
+            android:background="@color/black"
18
+            android:orientation="vertical">
19
+
20
+            <ImageView
21
+                android:id="@+id/iv_pop_back"
22
+                android:layout_width="45dp"
23
+                android:layout_height="45dp"
24
+                android:src="@drawable/pop_back"
25
+                android:padding="5dp"/>
26
+
27
+            <RelativeLayout
28
+                android:layout_width="match_parent"
29
+                android:layout_height="match_parent">
30
+
31
+                <com.android.views.PhotoView.UrlTouchImageView
32
+                    android:id="@+id/iv_full_screen_img"
33
+                    android:layout_width="match_parent"
34
+                    android:layout_height="wrap_content"
35
+                    android:layout_centerInParent="true"/>
36
+
37
+            </RelativeLayout>
38
+
39
+
40
+
41
+        </LinearLayout>
42
+
43
+    </RelativeLayout>
44
+</RelativeLayout>